package com.siwei.mes.entity.erp;

import com.siwei.mes.common.util.NullUtils;
import com.siwei.mes.entity.dto.PhbhistoryPhbDto;
import com.siwei.mes.entity.mixproportion.MixProportion;
import com.siwei.mes.entity.system.Signature;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;

/**
 * ERP任务单扩展信息打印修改记录(RwdextraPrintInfo)实体类
 *
 * @author yangke
 * @since 2024-11-29 22:59:50
 */
@Data
@Accessors(chain = true)
public class RwdextraPrintInfo {
    @ApiModelProperty(value = "打印电子签名表")
    private Signature signature;
    @ApiModelProperty(value = "客户信息")
    private Customer customer;
    @ApiModelProperty(value = "配合比信息")
    private MixProportion mixProportionInfo;
    @ApiModelProperty(value = "配合比信息(提供给前端修改用，实际存值是mixProportionInfo)")
    private MixProportion mixProportion;
    @ApiModelProperty(value = "ERP配合比修改信息(小票生产日期最近一次)")
    private Phbhistory phbhistory;
    @ApiModelProperty(value = "ERP配合比修改历史记录")
    private List<Phbhistory> phbhistoryList;
    @ApiModelProperty(value = "任务单信息")
    private Rwdextra rwdextra;
    @ApiModelProperty(value = "抗压台账样品编号数组")
    private List<String> kytzList;
    @ApiModelProperty(value = "抗压台账数组")
    private List<Kytz> kyInfoList;
    @ApiModelProperty(value = "抗折台账数组")
    private List<Kytz> kzInfoList;
    @ApiModelProperty(value = "抗渗台账协会样品编号")
    private String kstzypbh;
    @ApiModelProperty(value = "抗渗台账委托编号")
    private String kstzwtbh;
    @ApiModelProperty(value = "抗渗台账结论")
    private String kstzjl;
    @ApiModelProperty(value = "抗折台账协会委托编号")
    private String kztzypbh;
    @ApiModelProperty(value = "抗折台账委托编号")
    private String kztzwtbh;
    @ApiModelProperty(value = "抗折台账结论")
    private String kztzjl;
    @ApiModelProperty(value = "抗氯离子台账协会委托编号")
    private String kllztzypbh;
    @ApiModelProperty(value = "抗氯离子台账委托编号")
    private String kllztzwtbh;
    @ApiModelProperty(value = "抗氯离子台账结论")
    private String kllztzjl;
    @ApiModelProperty(value = "氯离子含量台账样品编号")
    private String llzhlypbh;
    @ApiModelProperty(value = "氯离子含量台账结论")
    private String llzhljl;
    @ApiModelProperty(value = "氯离子含量")
    private String llzhl;
    @ApiModelProperty(value = "实测坍落度")
    private String sctld;
    @ApiModelProperty(value = "实测粘聚性")
    private String sczjx;
    @ApiModelProperty(value = "实测保水性")
    private String scbsx;
    @ApiModelProperty(value = "抗压试验台账id")
    private Long kyExperimentId;
    @ApiModelProperty(value = "抗渗试验台账id")
    private Long ksExperimentId;
    @ApiModelProperty(value = "抗折试验台账id")
    private Long kzExperimentId;
    @ApiModelProperty(value = "抗氯离子试验台账id")
    private Long kllExperimentId;

    @ApiModelProperty(value = "配合比备注")
    private String phbbz;
    @ApiModelProperty(value = "出厂证明书备注")
    private String cczmsbz;
    @ApiModelProperty(value = "出厂证明签发日期")
    private String cczmqfrq;

    @ApiModelProperty(value = "计划方量")
    private String planQuantity;
    @ApiModelProperty(value = "浇筑部位")
    private String pouringPosition;
    @ApiModelProperty(value = "完成方量")
    private String FWcsl;
    @ApiModelProperty(value = "计划开始时间")
    private String plantimeStart;
    @ApiModelProperty(value = "出厂合格证编号")
    private String cchgzbh;
    @ApiModelProperty(value = "配合比报告编号")
    private String phbbgbh;
    @ApiModelProperty(value = "开盘鉴定编号")
    private String kpjdbh;

    @ApiModelProperty(value = "抗渗等级")
    private String ksdj;

    @Data
    @Accessors(chain = true)
    @ApiModel("客户信息")
    public static class Customer {
        @ApiModelProperty(value = "")
        private String bjbh;
        @ApiModelProperty(value = "")
        private String gcdz;
        @ApiModelProperty(value = "")
        private String jsdwName;
        @ApiModelProperty(value = "")
        private String buildName;
        @ApiModelProperty(value = "")
        private String projectName;
        @ApiModelProperty(value = "")
        private String erpProjectId;
        @ApiModelProperty(value = "")
        private String erpCustomerId;
        @ApiModelProperty(value = "")
        private String customerName;
        @ApiModelProperty(value = "计划开始时间")
        private String plantimeStart;
        @ApiModelProperty(value = "供应开始时间")
        private Date supplyStartTime;
        @ApiModelProperty(value = "供应结束时间")
        private Date supplyEndTime;
        @ApiModelProperty(value = "砼品种")
        private String ftpz;
        @ApiModelProperty(value = "配合比号")
        private String fPhbNo;
        @ApiModelProperty(value = "塌落度")
        private String tld;
        @ApiModelProperty(value = "完成方量")
        private String fhquantity;
    }

    @Data
    @Accessors(chain = true)
    @ApiModel("抗压台账数组")
    public static class Kytz {
        @ApiModelProperty(value = "试验台账ID")
        private String sytzbh = "";
        @ApiModelProperty(value = "委托编号")
        private String wtbh = "";
        @ApiModelProperty(value = "样品编号")
        private String ypbh = "";
        @ApiModelProperty(value = "协会委托编号")
        private String xhwtbh = "";
        @ApiModelProperty(value = "28d强度平均值")
        private String qdpjz = "";
        @ApiModelProperty(value = "达到设计强度")
        private String ddsjqd = "";
        @ApiModelProperty(value = "28天折算标准强度")
        private String zsbzqd = "";

    }

    public static boolean existsInArray(List<RwdextraPrintInfo.Kytz> kytzList, String value) {
        for (RwdextraPrintInfo.Kytz kytz : kytzList) {
            if (kytz.getSytzbh().equals(value)) {
                return true; // 找到匹配的值，返回true
            }
        }
        return false; // 遍历完数组没有找到，返回false
    }

    public void setValue(RwdextraPrintInfo rwdextraPrintInfo, RwdextraPrintInfo rwdextraPrintInfoNew) {
        rwdextraPrintInfo.setKytzList(rwdextraPrintInfoNew.getKytzList());
        rwdextraPrintInfo.setKyInfoList(rwdextraPrintInfoNew.getKyInfoList());
        rwdextraPrintInfo.setKsExperimentId(rwdextraPrintInfoNew.getKsExperimentId());
        rwdextraPrintInfo.setKstzwtbh(rwdextraPrintInfoNew.getKstzwtbh());
        rwdextraPrintInfo.setKstzypbh(NullUtils.ifNull(rwdextraPrintInfoNew.getKstzypbh()));
        rwdextraPrintInfo.setKstzjl(rwdextraPrintInfoNew.getKstzjl());
        rwdextraPrintInfo.setKzExperimentId(rwdextraPrintInfoNew.getKzExperimentId());
        rwdextraPrintInfo.setKztzypbh(NullUtils.ifNull(rwdextraPrintInfoNew.getKztzypbh()));
        rwdextraPrintInfo.setKztzwtbh(rwdextraPrintInfoNew.getKztzwtbh());
        rwdextraPrintInfo.setKztzjl(rwdextraPrintInfoNew.getKztzjl());
        rwdextraPrintInfo.setKllExperimentId(rwdextraPrintInfoNew.getKllExperimentId());
        rwdextraPrintInfo.setKllztzypbh(NullUtils.ifNull(rwdextraPrintInfoNew.getKllztzypbh()));
        rwdextraPrintInfo.setKllztzwtbh(rwdextraPrintInfoNew.getKllztzwtbh());
        rwdextraPrintInfo.setKllztzjl(rwdextraPrintInfoNew.getKllztzjl());
        rwdextraPrintInfo.setLlzhl(rwdextraPrintInfoNew.getLlzhl());
        rwdextraPrintInfo.setPhbbz(rwdextraPrintInfoNew.getPhbbz());
        rwdextraPrintInfo.setCczmsbz(rwdextraPrintInfoNew.getCczmsbz());
        rwdextraPrintInfo.setFWcsl(rwdextraPrintInfoNew.getFWcsl());
        rwdextraPrintInfo.setCczmqfrq(rwdextraPrintInfoNew.getCczmqfrq());
        rwdextraPrintInfo.setCchgzbh(rwdextraPrintInfoNew.getCchgzbh());
        rwdextraPrintInfo.setPhbbgbh(rwdextraPrintInfoNew.getPhbbgbh());
        rwdextraPrintInfo.setKpjdbh(rwdextraPrintInfoNew.getKpjdbh());
        MixProportion mixProportionInfo = rwdextraPrintInfo.getMixProportion();
        if(mixProportionInfo != null){
            rwdextraPrintInfoNew.getCustomer().setFPhbNo(mixProportionInfo.getProportionPhb());
            rwdextraPrintInfo.setMixProportionInfo(mixProportionInfo);
        }
        rwdextraPrintInfo.setCustomer(rwdextraPrintInfoNew.getCustomer());
        rwdextraPrintInfo.setKsdj(rwdextraPrintInfoNew.getKsdj());
        rwdextraPrintInfo.setCczmqfrq(rwdextraPrintInfoNew.getCczmqfrq());
    }

    public void setUpdate(RwdextraPrintInfo rwdextraPrintInfo, RwdextraPrintInfo rwdextraPrintInfoNew) {
        rwdextraPrintInfo.setPhbbz(rwdextraPrintInfoNew.getPhbbz());
        rwdextraPrintInfo.setCczmsbz(rwdextraPrintInfoNew.getCczmsbz());
        /* 修改为每次都更新三个字段
        rwdextraPrintInfo.setCczmqfrq(rwdextraPrintInfoNew.getCczmqfrq());
        if(!NullUtils.isNull(rwdextraPrintInfoNew.getPhbbz()) && !rwdextraPrintInfoNew.getPhbbz().equals(rwdextraPrintInfo.getPhbbz())){
            rwdextraPrintInfo.setPhbbz(rwdextraPrintInfoNew.getPhbbz());
        }
        if(!NullUtils.isNull(rwdextraPrintInfoNew.getCczmsbz()) && !rwdextraPrintInfoNew.getPhbbz().equals(rwdextraPrintInfo.getCczmsbz())){
            rwdextraPrintInfo.setCczmsbz(rwdextraPrintInfoNew.getCczmsbz());
        }
        if(!NullUtils.isNull(rwdextraPrintInfoNew.getCczmqfrq()) && !rwdextraPrintInfoNew.getPhbbz().equals(rwdextraPrintInfo.getCczmqfrq())){
            rwdextraPrintInfo.setCczmqfrq(rwdextraPrintInfoNew.getCczmqfrq());
        }*/
    }
}
